package com.wlzg.collectiontool.view

import android.os.Bundle
import android.view.View
import com.blankj.utilcode.util.SPUtils
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.BasePopupView
import com.wlzg.collectiontool.R
import kotlinx.android.synthetic.main.fragment_user.*

class UserFragment :BaseFragment(), View.OnClickListener {
    private var grzlPop: BasePopupView? = null
    private var xgmmPop: BasePopupView? = null
    private var banbenPop: BasePopupView? = null
    override fun getLayoutId(): Int = R.layout.fragment_user

    override fun initView(container: View?, savedInstanceState: Bundle?) {
        super.initView(container, savedInstanceState)
        grzl.setOnClickListener(this)
        banben.setOnClickListener(this)
        xgmm.setOnClickListener(this)
        logout.setOnClickListener(this)
        initPop()
    }

    private fun initPop() {
        grzlPop = XPopup.Builder(context).dismissOnTouchOutside(false).offsetY(80)
            .isCenterHorizontal(true)
            .asCustom(GrzlDIa(requireContext(), this))
        xgmmPop = XPopup.Builder(context).dismissOnTouchOutside(false).offsetY(80)
            .isCenterHorizontal(true)
            .asCustom(XgmmDIa(requireContext(), this))
    }

    override fun onClick(p0: View?) {
       when(p0?.id){
           R.id.grzl->{
               if (!grzlPop?.isShow!!) {
                   grzlPop?.show()
               }
           }
           R.id.xgmm->{
               if (!xgmmPop?.isShow!!) {
                   xgmmPop?.show()
               }
           }
           R.id.logout->{
               SPUtils.getInstance().put("Mlogin",false)
           }
       }
    }
}